package com.cqut.jdbc;

import com.cqut.utils.DBUtils;

public class dbdemo {
    private String dbpwd;

    public static void main(String[] args) {


//    public static void main(String[] args) throws SQLException{
//        String driver = "com.mysql.cj.jdbc.Driver";
//        String URL = "jdbc:mysql://localhost:3306/staff?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&useSSL=false";
//        String dbuser= "root";
//        String dbpwd= "181919";
//        Connection con = null;
//        try
//        {
//            Class.forName(driver);
//            con=DriverManager.getConnection(URL,"root","181919");//这里输入你自己安装MySQL时候设置的用户名和密码，用户名默认为root
//            System.out.println("连接成功.");
//            Statement stmt=con.createStatement();
//            String sql1 ="select * from staff";
//            ResultSet rs=stmt.executeQuery(sql1);
//            while(rs.next()){
//                System.out.println(rs.getString("tuser")+" "+rs.getString("pwd"));
//            }
//        }
//        catch(Exception e)
//        {
//            System.out.println("连接失败:" + e.getMessage());
//        }

        //        4. 定义sql语句
//        String sql="update account set balance =500 where id=1";
////        5. 获取执行sql语句的对象 statement
//        Statement statement =connection.createStatement();
////        6. 执行sql，接收返回结果
//        int count=statement.executeUpdate(sql);
////        7. 处理结果
//        System.out.println(count);
////        8. 释放资源
//        statement.close();
//        connection.close();
//        try {
//            String sql = "select * from student where studentsno =? ";
//            student e = DBUtils.QueryBean(sql, student.class,"bb");
//            System.out.println(e.toString());
//        }catch (Exception e){
//            e.printStackTrace();
//        }
    }
}
